﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using suirui.ZhuMu.Common;
using suirui.ZhuMu.Entity.Entities;
using suirui.ZhuMu.Middlewares;
using suirui.ZhuMu.Repositories;
using suirui.ZhuMu.Services;
using suirui.ZhuMu.WebCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace suirui.ZhuMu.MJGames
{
    public static class DIContainer
    {
        public static void RegisterDependencies(this IServiceCollection services, IConfiguration configuration)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));

            services.AddSingleton(new Appsettings(configuration));

            services.AddSingleton<CustomActionFilterAttribute>();
            services.AddSingleton<SignParamFilterAttribute>();
            services.AddSingleton<ImportModelService>();
            //services.AddScoped<dbRoomContext>();
            //登录
            services.AddScoped<ILoginRepository, LoginRepository>();
            services.AddScoped<ILoginService, LoginService>();
            //用户
            services.AddScoped<IUserRepository, UserRepository>();
            services.AddScoped<IUserService, UserService>();
            //房间
            services.AddScoped<IRoomRepository, RoomRepository>();
            services.AddScoped<IRoomService, RoomService>();

            //Redis
            //services.AddScoped<IRedisCacheManager, RedisCacheManager>();

            services.AddSingleton<Policies>();
        }
    }
}
